home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 October / macformat-029.iso / mac / Shareware City / Developers / Selection ƒ 2.5 / clipstuff < prev    next >
Encoding:
Text File  |  1994-11-06  |  1.3 KB  |  65 lines  |  [TEXT/MSET]

  1. (*
  2. Clipboard menu handlers for our standard selection  environment.  We only
  3. implemet text data, but of course we could generalize to pict data if we
  4. wish.
  5. *)
  6.  
  7.  
  8. : todesk    ( -- oserr )
  9.     0 call ZeroScrap IF exit THEN \ out if error
  10.     0    \ room for oserr
  11.     global TEScrpLength w@  \ length
  12.     'type TEXT    \ theType
  13.     global TEScrpHandle @ @
  14.     call PutScrap
  15.      ;
  16.  
  17. variable offset  \ used in GetScrap call
  18.  
  19.  : fromdesk    ( -- oserr )
  20.     0 \ room for result
  21.     global TEScrpHandle @
  22.     'type TEXT    \ theType
  23.     offset
  24.     call GetScrap
  25.     dup 0>=    IF global TEScrpLength w! \ store scrap length
  26.                false  \ no error
  27.             THEN
  28.     ; 
  29.  
  30. \ we hope that the actW knows about our standard clipboard messages:
  31. : selcut
  32.     actW IF cut: actW THEN ;
  33.  
  34. : selcopy
  35.     actW IF copy: actW THEN ;
  36.  
  37. : selpaste
  38.     actW IF paste: actW THEN ;
  39.  
  40. : selclear
  41.     actW IF clear: actW THEN ;
  42.  
  43. ' selcut ' xCut (patch)
  44. ' selcopy ' xCopy (patch)
  45. ' selpaste ' xPaste (patch)
  46. ' selclear ' xClear (patch)
  47.  
  48. endload
  49.  
  50. *** EXAMPLE USE
  51.  
  52. \ here is how we would set up the menu in an application, but this won't
  53. \ work for the Mops front end because Mops will setup its own menu
  54. \ handlers *after* init_actions is executed.  So we resorted to (patch), see above
  55. \ just for the development environment.
  56.  
  57. : initclip
  58.     xts{  xUndo null selcut selcopy selpaste selclear xSelAll null doPref  }
  59.      3  init: EditMen
  60. ;
  61.  
  62. \ ' initclip add: init_actions
  63.  
  64.  
  65.